class Clinic < Location
  
  def process(message)
    case message
    when NewPatientRecordUpdate, NewPatientRecordUpdateReply 
      send_to_doctor(message)
    when NewPatient
      # with some probabilty (Ba) will need to get updated medical record from HRC
      rand > B_a ? send_to_hrc(message) : send_to_doctor(message)
    when DoctorAction
      # with some probabilty (Bb) will need to get prescription
      send_to_pharmacy(message) if rand > B_b
      # with some probabilty (Bc) will need to get lab work
      send_to_lab(message) if rand > B_c
    when LabResults
      send_results_to_doctor(message)
    else
      super
    end
  end
  
#  def process
#    super do |message|
#      case message
#        when NewPatientRecordUpdate, NewPatientRecordUpdateReply
#          send_to_doctor(message)
#        when NewPatient
#          # with some probabilty (Ba) will need to get updated medical record from HRC
#          rand > B_a ? send_to_hrc(message) : send_to_doctor(message)
#      end
#    end
#  end  
  
  def send_results_to_doctor(message)
    MedSim.send((rand > B_d_1 ? 'dr_1':'dr_2'),message)
  end
  
  def send_to_doctor(message)
    MedSim.send((rand > B_d_1 ? 'dr_1':'dr_2'),NewPatient.new(message))
  end
  
  def send_to_hrc(message)
    MedSim.send('hrc',NewPatientRecordUpdate.new(message))
  end
  
  def send_to_lab(message)
    MedSim.send('lab',LabRequest.new(message))
  end
  
  def send_to_pharmacy(message)
    MedSim.send('pharmacy',Prescription.new(message))
  end
  
end